﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ChatModel;
using OrmChat;
using System.Runtime.Serialization.Json;

public partial class Contents_SilverChat : System.Web.UI.Page
{
		protected void Page_Load(object sender, EventArgs e)
		{

		}

		[System.Web.Services.WebMethod]
		[System.Web.Script.Services.ScriptMethod]
		public  static ChatRooms[] getChats()
		{
				try
				{
						var chats = new Chat().getChats();
						return chats; 
						//foreach (var item in dati)
						//{
						//  m_Chats += " &nbsp;<input id='Radio" + item.ChatRoomID + "' name='gruppone' type='radio'  title='" +
						//   item.Name + "'  value='" + item.ChatRoomID.ToString() +
						//   "' onclick=" + "\"" + "javascript:setIdChat(" + item.ChatRoomID + ",'" + item.Name + "');" + "\"" + "/>" + item.Name + " &nbsp;";
						//}
				}
				catch (Exception ex)
				{
						throw;
				}

		}//fm


		[System.Web.Services.WebMethod]
		[System.Web.Script.Services.ScriptMethod]
		public static myChatRoom[] getMyChats()
		{
				try
				{
						var chats = new Chat().getMyChats();
						
						return chats; 
						// var stream = new System.IO.MemoryStream();   
						//var json = System.Runtime.Serialization.Json.JsonReaderWriterFactory.CreateJsonWriter(stream);  
						//  json.WriteArray("","","",chats,0,chats.Length);
						 
						//DataContractJsonSerializer j = new DataContractJsonSerializer();
						//j.WriteObject(,);j.  
						
						//foreach (var item in dati)
						//{
						//  m_Chats += " &nbsp;<input id='Radio" + item.ChatRoomID + "' name='gruppone' type='radio'  title='" +
						//   item.Name + "'  value='" + item.ChatRoomID.ToString() +
						//   "' onclick=" + "\"" + "javascript:setIdChat(" + item.ChatRoomID + ",'" + item.Name + "');" + "\"" + "/>" + item.Name + " &nbsp;";
						//}
				}
				catch (Exception ex)
				{
						throw;
				}

		}//fm
		
		
		
		
}//fC
